package com.zhhs.galaxyott.httpVolley.parser;

import org.json.JSONException;
import org.json.JSONObject;

import com.zhhs.galaxyott.httpVolley.response.BaseResponse;
import com.zhhs.galaxyott.httpVolley.response.IsVipResponse;

/**
 * 是否是vip
 * 
 * 
 */
public class IsVipParser extends BaseParser<IsVipResponse> {

    @Override
    public BaseResponse parse(String jsonString) {
        IsVipResponse mResponse = new IsVipResponse();
        try {

            JSONObject json = new JSONObject(jsonString);
            parseMsg(json, mResponse);
            if (mResponse.errCode == 0) {
                if (json.has("isOnline")) {
                    mResponse.vipbean.setIsOnline(json.optString("isOnline"));
                }
                if (json.has("caId")) {
                    mResponse.vipbean.setCaId(json.optString("caId"));
                }
                if (json.has("result")) {
                    mResponse.vipbean.setResult(json.getInt("result"));
                }
                if (json.has("packageId")) {
                    mResponse.vipbean.setPackageId(json.optInt("packageId"));
                }
                if (json.has("packageName"))
                    mResponse.vipbean.setPackageName(json.optString("packageName"));
                if (json.has("packagePrice")) {
                    mResponse.vipbean.setPackagePrice(json.optDouble("packagePrice"));
                }
                if (json.has("effectDate")) {
                    mResponse.vipbean.setEffectDate(json.optString("effectDate"));
                }
                if (json.has("expiryDate")) {
                    mResponse.vipbean.setExpiryDate(json.optString("expiryDate"));
                }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return mResponse;
    }

}
